import 'dart:async';

import 'package:flutter/material.dart';
import 'package:selfapp/widgets/EducationPage.dart';
import 'package:selfapp/widgets/menu_page.dart';

class HomePage extends StatefulWidget{
  @override
  State<HomePage> createState() {
      return new _HomePageState();
  }


}

class _HomePageState extends State<HomePage>{

    Timer _t;
    @override
    void initState() {
        super.initState();
        _t = new Timer(const Duration(milliseconds: 1500), (){
            try{
              Navigator.of(context).pushAndRemoveUntil(
                  PageRouteBuilder<Null>(
                      pageBuilder: (BuildContext context,Animation<double> animation,
                        Animation<double> secondaryAnimation){
                          return AnimatedBuilder(
                            animation: animation,
                            builder: (BuildContext context,Widget child){
                              return Opacity(
                                opacity: animation.value,
                                child: MenuPage(),
                              );
                            },
                          );
                      },
                      transitionDuration:Duration(milliseconds: 3000),
                  ),
                  (Route route) => route == null);
            }catch (e){

            }
        });
    }


    @override
  void dispose() {
    _t.cancel();
    super.dispose();
  }

  @override
    Widget build(BuildContext context) {
        return new Material(
            color: Colors.lightGreen,
            child: Container(
              alignment: Alignment(0,-0.3),
              child: new Text(
                '把打游戏的时间用来学习。',
                textAlign: TextAlign.center,
                style: new TextStyle(
                    color: Colors.white,
                    fontSize: 25.0,
                    fontWeight: FontWeight.bold),
              ),
            ),
        );
    }


}
